//
// Created by Administrator on 2025/2/28.
//

#include "test.h"
#include <iostream>


#include <iostream>
#define VER 100;


class Base {
public:
    virtual ~Base() = default; // 基类必须具有虚函数
};

class Derived : public Base {
public:
    void show() {
        std::cout << "Derived class method" << std::endl;
    }
};

int test1() {
    Base* ptr_base = new Derived; // 基类指针指向派生类对象

    // 将基类指针转换为派生类指针
    Derived* ptr_derived = dynamic_cast<Derived*>(ptr_base);

    if (ptr_derived) {
        ptr_derived->show(); // 成功转换，调用派生类方法
    } else {
        std::cout << "Dynamic cast failed!" << std::endl;
    }

    delete ptr_base;
    return 0;
}

int test2() {
    const int i = 10;
    int& x = const_cast<int&> (i);

    // int& r = const_cast<int&>(i); // 常量转换，将const int转换为int
}


int test3() {
    int i = 10;
    long x = reinterpret_cast<long&>(i);
    wchar_t c = L'v';
    std::wcout << "as "<< c << std::endl;
    std::wcout << VER ;

    std::cout << "as";
    std::cout << VER;

    unsigned short int j =50000;
    short int h;
    h = j;
    std::wcout << "" << std::endl;
    std::wcout << h << std::endl;
    std::wcout << j << std::endl;


}


int main4() {
    test3();
    std::wcout << "as " << std::endl;
}



extern int count;

void write_extern(void)
{
    std::cout << "Count is " << count << std::endl;
}